<template>
  <div class="mcont">
      
  

    <div class="block">
         

     <el-input placeholder="请输入要搜索的展览名称或地点" v-model="title" class="input-with-select">
    <el-button slot="append" icon="el-icon-search" @click="findother"></el-button>
    
  </el-input>
  
      <el-timeline>
        <el-timeline-item :timestamp="blog.created" placement="top" v-for="(blog,key) in blogs" :key=key>
          
          <el-button type="danger" icon="el-icon-delete" circle @click="deletmylove(blog)"></el-button>
            <router-link :to="{name:'tickmsg',params:{blogId:blog.tickId}}"><!-- {blogId:blog.id}/-->
        


          <el-card>
                  <el-image  :src="blog.picture" :fit="fit" class="imgsize" style="width:10%;height:auto" ></el-image>
              
            <h4 >
                
                展览名:{{blog.title}}<br>日期:{{blog.starttime}}
                
            </h4>
            <p>地址:{{blog.description}}</p>
             
          </el-card>
          </router-link>
        </el-timeline-item>
      </el-timeline>

      <el-pagination class="mpage" background layout="prev, pager, next" 
      :current-page="currentpage" 
      :page-size="pageSize" 
      :total="total"
      @current-change=page
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import Header from "../components/Header";
export default {
  name: "Blogs.vue",
  components: { Header },
  data(){
      return {
          blogs:{},
          currentpage:1,
          total:0,
          title:'',
          pageSize:5,
          input3:'',
      }
  },
  methods:{
      page(currentpage){
      

          const _this = this
            this.$axios.get('/love/mylove?currentpage=' + currentpage, {
              headers: {
                "Authorization": localStorage.getItem("token")
              }
            }).then(res => {
                 console.log('currentpagemessage:')
          console.log(res)
          _this.blogs = res.data.data.records
          _this.currentpage = res.data.data.current
          _this.total = res.data.data.total
          _this.pageSize = res.data.data.size
          


            })


      },
     
      findother(currentpage){
            const _this = this
            console.log('111111111111111111111111111'+this.title+'end')//获取输入框的信息
            ///ticksFindName/{title}
        _this.$axios.get("/ticksFindName?title="+this.title).then(res => {
            
            console.log('currentpagemessage:')
          console.log(res)
          _this.blogs = res.data.data.records
          _this.currentpage = res.data.data.current
          _this.total = res.data.data.total
          _this.pageSize = res.data.data.size
          


          })
      },
      deletmylove(event){
        console.log('开始删除',event)
        console.log(event.tickId)

            const _this = this
            this.$axios.get('/love/del/'+event.id, {
              headers: {
                "Authorization": localStorage.getItem("token")
              }
            }).then(res => {
              console.log(res)
              _this.$alert('删除收藏成功', '提示', {
                confirmButtonText: '确定',
              }).then(ress=>{
                this.$router.go(0);
                location.reload()
              });
              

            })


      }
  },
  created(){
     
      console.log(this.page)
      this.page(1)
  }
};
</script>
<style scoped>
 .mpage{
     margin: 0 auto;
     text-align: center;
 }
</style>